package com.yyd.designmodel.strategy.impl;

import com.yyd.designmodel.strategy.Apple;
import com.yyd.designmodel.strategy.Discountable;
import com.yyd.designmodel.strategy.Discountor;

public class ApplePriceDiscountor implements Discountor {
	
	/**
	 * 购买满10元立减1元
     * 购买满20元立减3元
     * 购买满30元立减5元
	 */
	@Override
	public void discount(Discountable discountable) {
		Apple apple = (Apple)discountable;
		if(apple.getWeight() * apple.getPrice() < 10) {
            System.out.println("Apple未打折价钱:" + apple.getWeight() * apple.getPrice());
        }else if(apple.getWeight() * apple.getPrice() >= 10 && apple.getWeight() * apple.getPrice() < 20) {
            System.out.println("Apple购买满10元立减1元" + (apple.getWeight() * apple.getPrice() - 1) );
        }else if(apple.getWeight() * apple.getPrice() >= 20 && apple.getWeight() * apple.getPrice() < 30) {
            System.out.println("Apple购买满20元立减3元:" + (apple.getWeight() * apple.getPrice() - 3) );
        }else if(apple.getWeight() * apple.getPrice() >= 30) {
            System.out.println("Apple购买满30元立减5元:" + (apple.getWeight() * apple.getPrice() - 5) );
        }    
	}

}
